<?
include('../include/config.inc.php');
include('./Db_Mongo.inc.php');
$config['host'] =	'119.161.149.197';
$config['port']	=	'27017';
$config['usr']	=	'root';
$config['pass']	=	'manager';
$config['db']	=	'test';


$db = new MongodbClass($config);
/*
$re = $db->increase('jimmy',array('id'=>2),'n',2);
var_dump($re);
$re = $db->fetchAll('jimmy');
tree_array($re);
exit;
*/
$re = $db->set('44h33',99);
$re = $db->increment('44h33');
$re = $db->get('44h33');


echo "<pre>";
var_dump($re);
echo "</pre>";


/*
test instances

for($i=0;$i<20;$i++){
$item = array('id'=>$i, 'value'=>'value'.$i);
$re = $db->insertOne('jimmy',$item);
}
$re = $db->insertOne('jimmy',array('id'=>1,'value'=>'haha'));

$ar = array(array('id'=>'333'),array('id'=>'444','value'=>'dasfd'));
$re = $db->insertAll('jimmy',$ar);

$re = $db->replaceOne('jimmy','id',array('id'=>4,'value'=>'new value!'));

$re = $db->fetchOne('jimmy',array('id'=>1));
$re = $db->fetchAll('jimmy',array('id'=>1));
$re = $db->fetchLimit('jimmy',array('id'=>array( '$gt'=>3, '$lt'=>50)),array(),array('value'=>1),array(3,5));

$id = 17;
//tree_array($db->fetchAll('test',array("id" => $id)));
//$db->insertOne('test',array("id" => $id, "value" => $id, "haha"=>"hahahahah"));
$newdata = array('value'=> 'haha'.rand(10,99));
$re = $db->updateAll('test',array('id'=> $id), $newdata, 2);
var_dump($re);
tree_array($db->fetchAll('test',array("id" => $id)));

echo "<hr>";
$newdata = array('value'=>'new ---------------'.$id);
$re = $db->updateOne('jimmy',array('id'=> $id), $newdata);

$re = $db->increase('jimmy',array('id'=>2),'n',2);
*/

/*
$t = $db->fetchOne('jimmy',array('id'=>9));
var_dump($t);
$re = $db->updateById('jimmy',$t['_id'],array('value'=>'-------------update by id 9!'));
$db->query('jimmy',array('id'=>array('$gt'=>10,'$lt'=>20)));
*/
echo "<hr>";
$re = $db->fetchAll('key_value');
show_array($re);

